var foodList = {
	errorCB : function(tx, error) {
		alert("Error processing SQL: " + err.code);
	},
	showAdd : function(category, transition) {
		var template = $.createTemplateURL('templates/food_add.html');
		var html = template.get(category);
		app.loadHTML(html, {
			transition : transition
		})

	},
	add : function(name, price, unit, categoryInfo) {
		var db = app.getDB();
		db.transaction(function(tx) {
			tx.executeSql('insert into menu (name,unit_price,unit,category_id) VALUES(?,?,?,?)', [name, price, unit,
					categoryInfo.id], function(tx, results) {
				category.showDetail(categoryInfo, 'slide-right');
			}, errorCB);

		}, errorCB);
	},
	showUpdate : function(menu, categoryInfo, transtion) {
		var template = $.createTemplateURL('templates/food_edit.html');
		var html = template.get({
			menu : menu,
			category : categoryInfo
		});
		app.loadHTML(html, {
			transition : transtion
		})
	},
	update : function(name, price, unit, id, categoryInfo) {
		var db = app.getDB();
		db.transaction(function(tx) {
			tx.executeSql('update menu set name=? ,unit_price=?,unit=? where id=? ', [name, price, unit, id], function(
					tx, results) {
				category.showDetail(categoryInfo, 'slide-right');
			}, errorCB);

		}, errorCB);
	},
	deleteObj : function(id, categoryInfo) {
		app.msg.comfirm("提示", "确定要删除该菜品吗?", function() {
			var db = app.getDB();
			db.transaction(function(tx) {
				tx.executeSql('delete from  menu where id=? ', [id]);
			}, errorCB, function() {
				jsTouch.overlayClose();
				category.showDetail(categoryInfo, 'slide-right');
			});

		}, function() {
			jsTouch.overlayClose();
		})
	}

};